{header}
<table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">类型</th>
      <th scope="col">选题</th>
      <th scope="col">文案要求</th>
      <th scope="col">迅雷种子</th>
      <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody id="list">
    {copywrite_html}
    {clip_html}
  </tbody>
</table>
<script type="text/javascript">
  if (ws !== null) {
    ws.addEventListener('message', function (event) {
      var kv = str2kv(event.data);
      var data = event.data;
      if (kv['msg'] !== undefined && kv['msg'].indexOf('"-"') !== -1) {
        var msg_kv = kv['msg'].split('"-"');
        if (msg_kv[0] === 'msg' && msg_kv[1] === 'task_list') {
          $.post('{base_url}ws_lib/task_list', {
            skip_number: {skip_number}
          }, function (data) {
            var json = JSON.parse(data);
            var list = $('#list');
            list.empty();
            for (var i in json['copywrite']) {
              var tr = $('<tr></tr>');
              var th = $('<th scope="row">' + json['copywrite'][i]['id'] + '</th>');
              var td1 = $('<td>' + json['copywrite'][i]['topic_id'] + '</td>');
              var td2 = $('<td>' + json['copywrite'][i]['requirement'] + '</td>');
              var td3 = $('<td><a target="_blank" href="{base_url}uploads/' + json['copywrite'][i]['bt_file'] + '">下载</a></td>');
              var td4 = $('<td><a class="btn btn-primary" target="_blank" href="{base_url}view_copywrite_task?id=' + json['copywrite'][i]['id'] + '">查看</a></td>');
              tr.append(th, td1, td2, td3, td4);
              list.append(tr);
            }
            for (var i in json['clip']) {
              var tr = $('<tr></tr>');
              var th = $('<th scope="row">' + json['clip'][i]['id'] + '</th>');
              var td1 = $('<td>' + json['clip'][i]['topic_id'] + '</td>');
              var td2 = $('<td>{clip_require}</td>');
              var td3 = $('<td><a target="_blank" href="{base_url}uploads/bt_file/' + json['clip'][i]['bt_file'] + '">下载</a></td>');
              var td4 = $('<td><a class="btn btn-primary" target="_blank" href="{base_url}view_clip_task.php?id=' + json['clip'][i]['id'] + '">查看</a></td>');
              tr.append(th, td1, td2, td3, td4);
              list.append(tr);
            }
          });
        }
      } else if (data.indexOf(':') !== -1) {
        var d = data.split(':');
        if (d[0] === 'fail') {
          layer.alert('系统错误，' + d[1], {icon:2});
          return;
        }
      }
    });
  }
</script>
{nav}
{footer}

